<?php

namespace Database\Seeders;

use App\Models\Permission;
use Illuminate\Database\Seeder;

class PermissionSeeder extends Seeder
{
  /**
   * Run the database seeds.
   */
  public function run()
  {
    $actions = [
      'read',     // index, show
      'manage',   // store, update
      'delete',   // destroy
    ];

    $qryparams = create_qry_params();

    $tables = [
      'users',
      'roles',
      'permissions',
      'countries',
      'languages',
      'locales',
      'regions',
      'districts',
      'cities',
      'zipcodes',
      'people',
      'companies',
      'types',
      'addresses',
      'telephones',
      'emails',
      'pictures'
    ];

    foreach ($tables as $table) {
      foreach ($actions as $action) {
        Permission::create([
          'slug' => $action . '-' . $table,
          'name' => ucfirst($action) . ' ' . $table,
        ]);
      }
    }
  }
}
